package com.shigu.admin.action;

import com.shigu.MallResponse;
import com.shigu.PageRequest;
import com.shigu.PageResponse;
import com.shigu.cron.MoneyReportTask;
import com.shigu.dailyReport.bo.ReportRequest;
import com.shigu.dailyReport.service.DailyReportService;
import com.shigu.dailyReport.vo.DailyReportVo;
import com.shigu.dailyReport.vo.TradeReportResponse;
import com.shigu.dailyReport.vo.VipReportResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.ParseException;


@Controller
@RequestMapping("adminjson")
public class ReportController {
    @Autowired
    DailyReportService dailyReportService;
    @Autowired
    MoneyReportTask moneyReportTask;

    @RequestMapping("dailyReportList")
    @ResponseBody
    public PageResponse<DailyReportVo> dailyReportList(PageRequest request){
        return dailyReportService.dailyReportList(request.getPage(),request.getSize());
    }

    @RequestMapping("tradeReport")
    @ResponseBody
    public TradeReportResponse tradeReport(ReportRequest request){
        return dailyReportService.tradeReport(request.getDate());
    }

    @RequestMapping("vipReport")
    @ResponseBody
    public VipReportResponse vipReport(ReportRequest request){
        return dailyReportService.vipReport(request.getDate());
    }

    @RequestMapping("dateReport")
    @ResponseBody
    public MallResponse dateReport(ReportRequest request) throws ParseException {
        moneyReportTask.productDailyReport(request.getDate());
        return new MallResponse().success();
    }
}


